package com.kehon.sevletdemo;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author zhang peng yang ming
 * @CopyRight (C) http://www.csdn.com
 * @brief
 * @email 122162005@qq.com
 * @date 2018-07-16
 */
public class AddEmpServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        // 解决乱码
        servletResponse.setContentType("text/html;charset=UTF-8");

        // 获取输出流
        PrintWriter writer = servletResponse.getWriter();
        String html = "<form action=\"\" method=\"post\">\n" +
                "                <table>\n" +
                "                    <tr>\n" +
                "                        <td colspan=\"2\"><input class=\"username\" type=\"text\" name=\"username\" placeholder=\"您的用户名\"/></td>\n" +
                "                    </tr>\n" +
                "                    <tr>\n" +
                "                        <td colspan=\"2\"><input class=\"password\" type=\"password\" name=\"password\" placeholder=\"您的密码\"/></td>\n" +
                "                    </tr>\n" +
                "                    <tr>\n" +
                "                        <!-- 单选框 -->\n" +
                "                        <td>性&nbsp;&nbsp;别</td>\n" +
                "                        <td><input type=\"radio\" name=\"sex\" value=\"0\"/>男<input type=\"radio\" name=\"sex\" value=\"1\"/>女<input type=\"radio\" name=\"sex\" value=\"2\"/>保密</td>\n" +
                "                    </tr>\n" +
                "                    <tr>\n" +
                "                        <!-- 头像 -->\n" +
                "                        <td>头&nbsp;&nbsp;像</td>\n" +
                "                        <td><input type=\"file\" /></td>\n" +
                "                    </tr>\n" +
                "                    <tr>\n" +
                "                        <!-- 头像 -->\n" +
                "                        <td>爱&nbsp;&nbsp;好</td>\n" +
                "                        <td>\n" +
                "                            <input type=\"checkbox\" name=\"hobby\" value=\"足球\"/>足球\n" +
                "                            <input type=\"checkbox\" name=\"hobby\" value=\"篮球\"/>篮球\n" +
                "                            <input type=\"checkbox\" name=\"hobby\" value=\"lol\"/>英雄联盟\n" +
                "                        </td>\n" +
                "                    </tr>\n" +
                "                    <tr>\n" +
                "                        <!-- 头像 -->\n" +
                "                        <td>省&nbsp;&nbsp;份</td>\n" +
                "                        <td>\n" +
                "                            <select name=\"province\">\n" +
                "                                <option value=\"1\">四川省</option>\n" +
                "                                <option value=\"2\">云南省</option>\n" +
                "                                <option value=\"3\">贵州省</option>\n" +
                "                                <option value=\"4\" selected=\"selected\">西藏</option>\n" +
                "                                <option value=\"5\">甘肃省</option>\n" +
                "                                <option value=\"6\">陕西省</option>\n" +
                "                                <option value=\"7\">重庆</option>\n" +
                "                            </select>\n" +
                "                        </td>\n" +
                "                    </tr>\n" +
                "                </table>\n" +
                "                <p>\n" +
                "                    <input class=\"submit\" type=\"submit\" onclick=\"testFunction()\" value=\"保存\" />\n" +
                "                    <input class=\"reset\" type=\"reset\" onclick=\"testFunction()\" value=\"重置\" />\n" +
                "                </p>\n" +
                "            </form>";
        writer.println(html);
        writer.close();
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
